
public class Board
{
   
   
   private Piece[][] board;
   
   public Board(int limit)
   {
      board = new Piece[limit][limit];
   }
   
   public Piece getPiece(Position pos)
   {
      return board[pos.row][pos.col];
   }
   
   public boolean removePiece(Position pos)
   {
      if(getPiece(pos) != null)
      {
         board[pos.row][pos.col] = null;
         return true;
      }
      else
      {
         return false;
      }
   }
   
   public boolean putPiece(Piece p)
   {
      Position pos = p.getPosition();
      if(getPiece(pos) == null)
      {
         board[pos.row][pos.col] = p;
         return true;
      }
      else
      {
         return false;
      }
   }
   public String printBoard()
   {
      String result = "";
      for(int i=0;i<8;i++)
      {
         for(int j=0;j<8;j++)
         {
            Piece p = board[i][j];
            if(p != null)
            {
               result+="P" + p.getPlayer() + " ";
            }
            else
            {
               result+="00 ";
            }
         }
         result+="\n";
      }
      return result;
   }
}
